package org.farm2.base.event;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/**
 * 定义一个事件
 */
@Data
public class F2Event {
    F2EObject obj;
    F2EAction action;
    String note;

    public F2Event(F2EObject obj, F2EAction action, String note) {
        this.obj = obj;
        this.action = action;
        if (StringUtils.isNotBlank(note)) {
            if (note.length() > 256) {
                this.note = note.substring(0, 255);
            } else {
                this.note = note;
            }
        }
    }

    public String toString() {
        return obj.getType().getTitle() + "_" + action.getType().getTitle();
    }
}
